Skip to content

fix: use shared uv cache for package tests#832

Merged
mangelajo merged 2 commits into
mainfrom
fix/shared-uv-cache
Jun 23, 2026
Merged

fix: use shared uv cache for package tests#832
mangelajo merged 2 commits into
mainfrom
fix/shared-uv-cache

Conversation

@mangelajo

Copy link
Copy Markdown
Member

Problem

The Makefile test targets (pkg-test-%) set UV_CACHE_DIR to a separate directory per package (.uv-cache/<pkg>). This means each package's test venv downloads and builds its own copy of shared dependencies like grpcio, protobuf, etc., even though they're identical across packages.

Fix

Remove the UV_CACHE_DIR override entirely, letting uv use its default shared cache (~/.cache/uv on Linux, ~/Library/Caches/uv on macOS). This way all package test runs share cached downloads and built wheels, avoiding redundant work.

Impact

  • Faster local test runs: common dependencies are downloaded/built once and reused across all packages
  • CI can still override UV_CACHE_DIR via environment if a custom cache path is needed for persistence

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Three targeted changes to python/Makefile: PYTHONUNBUFFERED=1 is added to the pkg-test-% invocation when LOGS_DIR is set, the per-package UV_CACHE_DIR override is removed from the non-LOGS_DIR path, and pkg-test-all gains sync as a prerequisite.

Changes

pkg-test Makefile updates

Layer / File(s) Summary
pkg-test-% and pkg-test-all adjustments
python/Makefile
When LOGS_DIR is set, PYTHONUNBUFFERED=1 is prepended to the uv run … pytest command so log output is not buffered. When LOGS_DIR is unset, the per-package UV_CACHE_DIR="$(CURDIR)/.uv-cache/$*" override is removed. pkg-test-all adds sync as a prerequisite before the per-package test targets.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • jumpstarter-dev/jumpstarter#815: Modifies the same pkg-test-% target in python/Makefile, specifically how uv run pytest is invoked and how test output is handled under LOGS_DIR.

Suggested reviewers

  • raballew

Poem

🐇 A hop through the Makefile, quick as can be,
PYTHONUNBUFFERED now sets the logs free,
No cache dir to clutter each package's run,
And sync comes first before tests are begun,
Small tweaks, tidy fixes — the rabbit approves! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: removing per-package UV_CACHE_DIR overrides to use the shared uv cache instead.
Description check ✅ Passed The description clearly explains the problem, solution, and impact of using a shared uv cache for package tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/shared-uv-cache

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
python/Makefile (2)

102-102: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Declare pkg-test-all as a PHONY target.

The pkg-test-all target doesn't create a file with that name, so it should be declared as .PHONY to ensure it always runs even if a file named pkg-test-all exists in the directory.

📝 Proposed fix to add PHONY declaration

Add the target to the .PHONY declaration (likely near the top or bottom of the Makefile):

+.PHONY: pkg-test-all
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/Makefile` at line 102, The target `pkg-test-all` does not have a PHONY
declaration, which means Make will treat it as a file target and may skip
execution if a file with that name exists in the directory. Add `pkg-test-all`
to the existing `.PHONY` declaration at the top of the Makefile (typically near
other PHONY declarations like `.PHONY: sync, test, etc.`) to ensure this target
always executes regardless of whether a file with that name is present.

Source: Linters/SAST tools


88-88: 📐 Maintainability & Code Quality | 🔵 Trivial

Consider adding PYTHONUNBUFFERED=1 to the non-LOGS_DIR path for consistency.

Currently, PYTHONUNBUFFERED=1 is set only on line 88 (where output is piped through tee to a log file), but not on line 96 (direct terminal output). While unbuffered output is essential for real-time log capture with tee, adding it to line 96 would provide immediate test output feedback during local development without needing to wait for buffer flushes. This is optional but improves consistency across both code paths.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/Makefile` at line 88, The `PYTHONUNBUFFERED=1` environment variable is
currently only set on the pytest command that pipes output to a log file via tee
(line 88), but is missing from the other pytest invocation that outputs directly
to the terminal (line 96). Add `PYTHONUNBUFFERED=1` to the `uv run` command on
line 96 to match the configuration on line 88 and ensure consistent unbuffered
output behavior across both code paths, providing immediate test feedback during
local development.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@python/Makefile`:
- Line 102: The target `pkg-test-all` does not have a PHONY declaration, which
means Make will treat it as a file target and may skip execution if a file with
that name exists in the directory. Add `pkg-test-all` to the existing `.PHONY`
declaration at the top of the Makefile (typically near other PHONY declarations
like `.PHONY: sync, test, etc.`) to ensure this target always executes
regardless of whether a file with that name is present.
- Line 88: The `PYTHONUNBUFFERED=1` environment variable is currently only set
on the pytest command that pipes output to a log file via tee (line 88), but is
missing from the other pytest invocation that outputs directly to the terminal
(line 96). Add `PYTHONUNBUFFERED=1` to the `uv run` command on line 96 to match
the configuration on line 88 and ensure consistent unbuffered output behavior
across both code paths, providing immediate test feedback during local
development.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b5cd71ea-4963-4bd7-8b1a-af05ffb3eb4c

📥 Commits

Reviewing files that changed from the base of the PR and between 86c308e and 6824831.

📒 Files selected for processing (1)
  • python/Makefile

Remove per-package UV_CACHE_DIR override from Makefile test targets.
Previously each package set UV_CACHE_DIR to a separate directory
(.uv-cache/<pkg>), preventing packages from sharing cached downloads
and built wheels. This caused redundant downloads and builds of common
dependencies (grpcio, protobuf, etc.) across every package test run.

By using uv's default shared cache (~/.cache/uv on Linux,
~/Library/Caches/uv on macOS), all package test venvs now reuse the
same cached artifacts, significantly speeding up test runs.
Run 'uv sync --all-packages --all-extras' before parallel pkg-test-%
targets to ensure all dependencies are already cached. This avoids
cache write contention during parallel test runs while still benefiting
from a shared cache.
@mangelajo mangelajo force-pushed the fix/shared-uv-cache branch from 6824831 to 46a8f9b Compare June 23, 2026 20:02

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@python/Makefile`:
- Line 102: The `pkg-test-all` target is not declared as a phony target in the
Makefile, which can cause Make to skip execution if a file or directory named
`pkg-test-all` exists. Add `pkg-test-all` to the `.PHONY` declaration at the top
of the Makefile alongside other phony targets to ensure this target always
executes regardless of filesystem state.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8736e299-1595-4142-9034-19a5acbf5c62

📥 Commits

Reviewing files that changed from the base of the PR and between 6824831 and 46a8f9b.

📒 Files selected for processing (1)
  • python/Makefile

Comment thread python/Makefile
uv run --isolated --directory $< ty check .

pkg-test-all: $(addprefix pkg-test-,$(PKG_TARGETS))
pkg-test-all: sync $(addprefix pkg-test-,$(PKG_TARGETS))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Declare pkg-test-all as phony to avoid accidental no-op builds.

If a file/directory named pkg-test-all exists, make can treat the target as up-to-date and skip running the package tests.

Suggested fix
+.PHONY: pkg-test-all
 pkg-test-all: sync $(addprefix pkg-test-,$(PKG_TARGETS))
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
pkg-test-all: sync $(addprefix pkg-test-,$(PKG_TARGETS))
.PHONY: pkg-test-all
pkg-test-all: sync $(addprefix pkg-test-,$(PKG_TARGETS))
🧰 Tools
🪛 checkmake (0.3.2)

[warning] 102-102: Target "pkg-test-all" should be declared PHONY.

(phonydeclared)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/Makefile` at line 102, The `pkg-test-all` target is not declared as a
phony target in the Makefile, which can cause Make to skip execution if a file
or directory named `pkg-test-all` exists. Add `pkg-test-all` to the `.PHONY`
declaration at the top of the Makefile alongside other phony targets to ensure
this target always executes regardless of filesystem state.

Source: Linters/SAST tools

@mangelajo mangelajo enabled auto-merge June 23, 2026 20:16
@mangelajo mangelajo added this pull request to the merge queue Jun 23, 2026
Merged via the queue into main with commit 8cc61e1 Jun 23, 2026
21 checks passed
@mangelajo mangelajo deleted the fix/shared-uv-cache branch June 23, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants